package com.ling.tools.login.oauth;

import com.ling.tools.login.entity.User;
import com.ling.tools.login.service.UserService;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * File Name: OAuthRealm
 * Date: 2020/2/29 16:59
 * Author: liangling
 * Description 自定义shrioRealm（验证规则）
 */
public class OAuthRealm extends AuthorizingRealm {

    @Autowired
    private UserService userService;


    /**
      * @author Ling
      * @Param
      * @Date 2020/2/29 17:08
      * @Description  授权管理
      * @return
      */
    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
       String account = (String)principalCollection.getPrimaryPrincipal();
        User user = userService.findUserByAccount(account);
        if(null == user){

        }

        return null;
    }

     /**
       * @author Ling
       * @Param
       * @Date 2020/2/29 17:11
       * @Description 验证
       * @return
       */
    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
        return null;
    }
}
